import 'package:elephant_fish/page/room_manager_my_room_page.dart';
import 'package:elephant_fish/page/room_manager_my_studio_page.dart';
import 'package:elephant_fish/util/size_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class RoomManagerPage extends StatefulWidget {
  const RoomManagerPage({Key key}) : super(key: key);

  @override
  _RoomManagerPageState createState() => _RoomManagerPageState();
}

class _TabData {
  final Widget tab;
  final Widget body;

  _TabData({this.tab, this.body});
}

final _tabDataList = <_TabData>[
  _TabData(
      tab: Text('我的直播间'),
      body: RoomManagerMyStudioPage(

      )),
  _TabData(
      tab: Text('我的房间'),
      body: RoomManagerMyRoomPage(
      )),
];


class _RoomManagerPageState extends State<RoomManagerPage> {
  final tabBarList = _tabDataList.map((item) => item.tab).toList();
  final tabBarViewList = _tabDataList.map((item) => item.body).toList();
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(length: tabBarList.length,
        child: Scaffold(
          backgroundColor: Color(0xff140c3d),
          appBar: AppBar(
            backgroundColor: Color(0xff140c3d),
            centerTitle: true,
            leading: GestureDetector(
              child: Icon(
                Icons.arrow_back_ios,
                size: SizeUtil.px(32),
                color: Color(0xfff3f3f3),
              ),
              onTap: () {
                Navigator.pop(context);
              },
            ),
            title: Row(
              children: [
                Expanded(child: TabBar(
                  // isScrollable: true, //可滚动
                  indicatorColor: Color(0xffff215d), //指示器的颜色
                  labelColor: Color(0xfff5f5f5), //选中文字颜色
                  unselectedLabelColor: Color(0xfff5f5f5), //为选中文字颜色
                  // isScrollable: true,
                  unselectedLabelStyle: TextStyle(
                    fontSize: SizeUtil.px(32),
                  ),
                  labelStyle: TextStyle(
                    fontSize: SizeUtil.px(32),
                  ),
                  // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
                  tabs: tabBarList,
                ),

                ),

              ],
            ),
          ),
          body:
          TabBarView(
              children: tabBarViewList
          ),
        ));
  }
}
